package com.shtel.paas.monitorcenter.monitoring.alarm.management.warn.notice.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.shtel.paas.monitorcenter.monitoring.alarm.management.warn.notice.entity.WarnNoticeEntity;
import com.shtel.paas.monitorcenter.monitoring.alarm.management.warn.notice.service.WarnNoticeService;
import com.shtel.paas.monitorcenter.monitoring.alarm.management.warn.notice.vo.WarningNoticeCountVo;
import com.shtel.paas.monitorcenter.system.management.user.management.vo.MonitoringCenterUserVo;
import com.shtel.paas.monitorcenter.util.Page;

/**
 * 
 * @author zhaochuan.zhong
 *
 */
// @EnablePaasMybatis
@MapperScan("com.shtel.paas.monitorcenter.monitoring.alarm.management.warn.notice.mapper")
// mybatis存储库类的包路径
@RestController
public class WarnNoticeController {

	@Autowired
	private WarnNoticeService warnNoticeService;

	/**
	 * 用户信息列表数据获取
	 */
	@GetMapping("/selectWarnNtticeInfo")
	public Page<MonitoringCenterUserVo> getWarnNotice(
			@RequestParam("monitoringStatus") String monitoringStatus,
			@RequestParam("monitoringIndex") String monitoringIndex,
			@RequestParam("idexKpi") String idexKpi,
			@RequestParam("earlyWarningLevel") String earlyWarningLevel,
			@RequestParam("startTime") String startTime,
			@RequestParam("endTime") String endTime,
			@RequestParam("page") Integer page,
			@RequestParam("size") Integer pageSize) {
		WarnNoticeEntity rmpEnt = new WarnNoticeEntity();
		rmpEnt.setMonitoringStatus(monitoringStatus);
		rmpEnt.setEarlyWarningLevel(earlyWarningLevel);
		rmpEnt.setIdexKpi(idexKpi);
		rmpEnt.setMonitoringIndex(monitoringIndex);
		rmpEnt.setStartTime(startTime);
		rmpEnt.setEndTime(endTime);
		rmpEnt.setSize(pageSize);
		rmpEnt.setPage(page);
		Page<MonitoringCenterUserVo> pageContent = warnNoticeService
				.selectUserInfo(rmpEnt);
		return pageContent;
	}

	/**
	 * 当前报警和历史报警数据获取
	 */
	@GetMapping("/getAlarmCount")
	public List<WarningNoticeCountVo> getAlarmCount(
			@RequestParam("monitoringStatus") String monitoringStatus,
			@RequestParam("monitoringIndex") String monitoringIndex,
			@RequestParam("idexKpi") String idexKpi,
			@RequestParam("earlyWarningLevel") String earlyWarningLevel,
			@RequestParam("startTime") String startTime,
			@RequestParam("endTime") String endTime) {
		WarnNoticeEntity rmpEnt = new WarnNoticeEntity();
		rmpEnt.setMonitoringStatus(monitoringStatus);
		rmpEnt.setEarlyWarningLevel(earlyWarningLevel);
		rmpEnt.setIdexKpi(idexKpi);
		rmpEnt.setMonitoringIndex(monitoringIndex);
		rmpEnt.setStartTime(startTime);
		rmpEnt.setEndTime(endTime);

		List<WarningNoticeCountVo> selectNowWarnNmAndHistoryWarnNm = warnNoticeService
				.selectNowWarnNmAndHistoryWarnNm(rmpEnt);
		return selectNowWarnNmAndHistoryWarnNm;
	}

	/**
	 * 用户信息列表数据获取
	 */
	@GetMapping("/getWarnEchart")
	public Map<String, Object> getWarnEchart(
			@RequestParam("monitoringStatus") String monitoringStatus,
			@RequestParam("monitoringIndex") String monitoringIndex,
			@RequestParam("idexKpi") String idexKpi,
			@RequestParam("earlyWarningLevel") String earlyWarningLevel,
			@RequestParam("startTime") String startTime,
			@RequestParam("endTime") String endTime) {
		WarnNoticeEntity rmpEnt = new WarnNoticeEntity();
		rmpEnt.setMonitoringStatus(monitoringStatus);
		rmpEnt.setEarlyWarningLevel(earlyWarningLevel);
		rmpEnt.setIdexKpi(idexKpi);
		rmpEnt.setMonitoringIndex(monitoringIndex);
		rmpEnt.setStartTime(startTime);
		rmpEnt.setEndTime(endTime);
		Map<String, Object> results = new HashMap<String, Object>();
		results = warnNoticeService.selectNowWarnNmForBar(rmpEnt);
		return results;
	}

	/**
	 * 搜索部分下拉框的值
	 */
	@GetMapping("/getSelectOptionValue")
	public Map<String, Object> getSelectOptionValue() {

		Map<String, Object> results = new HashMap<String, Object>();
		results = warnNoticeService.selectOptionValue();
		return results;
	}
}
